

package GUI_3GE;

import exeptions.ControlledUserException;
import java.awt.CardLayout;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import pkg3hge_plh24.*;

   

public class UserFrame extends javax.swing.JFrame {

 private DBManager dbm;
 private Users controlledUser;
 private SearchRestaurantFrame sR;
 
  
    public UserFrame(DBManager dbm, Users controlledUser) {
        initComponents();
        
        this.dbm = dbm;
        this.controlledUser=controlledUser;
        
     
        
    }

   


    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        userLogoLabel = new javax.swing.JLabel();
        userTextLabel = new javax.swing.JLabel();
        userSearchRestaurantButton = new javax.swing.JButton();
        userStartServiceButton = new javax.swing.JButton();
        userStopServiceButton = new javax.swing.JButton();
        userExitButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Εφαρμογή City Guide");

        userLogoLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI_3GE/logo.png"))); // NOI18N
        userLogoLabel.setToolTipText("");
        userLogoLabel.setMaximumSize(new java.awt.Dimension(1145, 395));

        userTextLabel.setFont(new java.awt.Font("Tahoma", 1, 12));
        userTextLabel.setText("Συνδεθήκατε ως χρήστης");
        userTextLabel.setToolTipText("");

        userSearchRestaurantButton.setText("Αναζήτηση Εστιατορίου");
        userSearchRestaurantButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                userSearchRestaurantButtonActionPerformed(evt);
            }
        });

        userStartServiceButton.setText("Εκκίνηση Υπηρεσίας");

        userStopServiceButton.setText("Διακοπή Υπηρεσίας");

        userExitButton.setText("Έξοδος");
        userExitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                userExitButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(userExitButton, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                    .addComponent(userStopServiceButton, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                    .addComponent(userStartServiceButton, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(userSearchRestaurantButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(userLogoLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(18, 18, 18)
                .addComponent(userTextLabel)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(userLogoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(userSearchRestaurantButton)
                    .addComponent(userTextLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(userStartServiceButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(userStopServiceButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(userExitButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void userExitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_userExitButtonActionPerformed
       System.exit(0); //έξοδος
    }//GEN-LAST:event_userExitButtonActionPerformed

private void userSearchRestaurantButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_userSearchRestaurantButtonActionPerformed
// TODO add your handling code here:
 SearchRestaurantFrame sr = null;
        try {
            sr = new SearchRestaurantFrame(dbm, controlledUser);
        } catch (ControlledUserException ex) {
            Logger.getLogger(UserFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
         sr.setVisible(true);
         this.dispose();
}//GEN-LAST:event_userSearchRestaurantButtonActionPerformed

 
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton userExitButton;
    private javax.swing.JLabel userLogoLabel;
    private javax.swing.JButton userSearchRestaurantButton;
    private javax.swing.JButton userStartServiceButton;
    private javax.swing.JButton userStopServiceButton;
    private javax.swing.JLabel userTextLabel;
    // End of variables declaration//GEN-END:variables

}
